package com.yy.web.pm.user.domain;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Collections;

public class OpenIdUser implements UserDetails {
    private final String openid;

    public OpenIdUser(String openid) {
        this.openid = openid;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        // 返回一个基础权限（必须非空）
        return Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
    }

    @Override public String getPassword() { return ""; }
    @Override public String getUsername() { return this.openid; }
    @Override public boolean isAccountNonExpired() { return true; }
    @Override public boolean isAccountNonLocked() { return true; }
    @Override public boolean isCredentialsNonExpired() { return true; }
    @Override public boolean isEnabled() { return true; }
}
